package com.zbkj.dal.common.utils;

import org.apache.commons.lang3.StringUtils;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.Locale;
import java.util.Objects;

public class DateConverter {

    public static String convertDate(LocalDate date) {
        if (Objects.isNull(date)) {
            return StringUtils.EMPTY;
        }
        LocalDate today = LocalDate.now();
        if (date.equals(today.minusDays(2))) {
            return "前天";
        } else if (date.equals(today.minusDays(1))) {
            return "昨天";
        } else if (date.equals(today)) {
            return "今天";
        } else if (date.equals(today.plusDays(1))) {
            return "明天";
        } else if (date.equals(today.plusDays(2))) {
            return "后天";
        } else {
            return date.format(DateTimeFormatter.ofPattern("EEEE", Locale.getDefault()));
        }
    }
}
